from functools import wraps

from flask import session
from werkzeug.exceptions import NotFound


def is_login(function):
    @wraps(function)
    def wrap(*args, **kwargs):
        if session.get('user', ''):
            return function(*args, **kwargs)
        else:
            raise NotFound

    return wrap
